@PACKAGE_INIT@

include(CMakeFindDependencyMacro)

set(_@PROJECT_NAME@_supported_components Core Binarize Convert)

set(Core_deps "@Core_DOWNSTREAM_DEPS@")
set(Binarize_deps "@Binarize_DOWNSTREAM_DEPS@")
set(Convert_deps "@Convert_DOWNSTREAM_DEPS@")
set(Boost_comps "@Boost_DOWNSTREAM_COMPONENTS@")

set(_comps ${@PROJECT_NAME@_FIND_COMPONENTS})
if (_comps)
  if ("Convert" IN_LIST _comps)
    list(PREPEND _comps Binarize)
  endif ()
  list(PREPEND _comps Core)
  list(REMOVE_DUPLICATES _comps)
else() # empty list of components, include all
  set(_comps ${_@PROJECT_NAME@_supported_components})
endif ()

foreach(_comp ${_comps})
  if (NOT _comp IN_LIST _@PROJECT_NAME@_supported_components)
    set(@PROJECT_NAME@_FOUND False)
    set(@PROJECT_NAME@_NOT_FOUND_MESSAGE "Unsupported component: ${_comp}")
  endif()
  include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@${_comp}Targets.cmake")

  foreach (_pkg_ver ${${_comp}_deps})
    # Use regular expression to extract package name and version
    string(REGEX MATCH "^(.*)_([0-9]+\\.[0-9]+\\.?[0-9]*)$" extracted_parts ${_pkg_ver})

    # Access the extracted groups
    set(package_name ${CMAKE_MATCH_1})
    set(package_version ${CMAKE_MATCH_2})
    set(comps ${${package_name}_comps})

    if (comps)
      find_dependency(${package_name} ${package_version} COMPONENTS ${comps})
    else ()
      find_dependency(${package_name} ${package_version})
    endif ()
  endforeach()

endforeach()



